package com.asdhawaii.otello.board;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the BoardPanel class.
 * 
 * @author Branden Ogata
 *
 */

public class TestBoardPanel
{
  /**
   * Tests the logic in the BoardPanel class.
   * Later testing may incorporate testing of the graphics, but as there are no graphics
   * in the current version it is rather difficult to test for them.
   * 
   */
  
  @Test
  public void test()
  {
    // The boards to test
    BoardPanel starting = new BoardPanel();
    BoardPanel play = new BoardPanel();
    
    // Upon starting, the boards should be equal
    assertTrue("Test initial Board equality with equals", starting.equals(play));
    assertEquals("Test initial Board equality with hashCode", starting.hashCode(), play.hashCode());
    
    // Place a Black piece at d5, a valid move
    assertTrue("Black piece to d5 should be valid", play.place(3, 5, SquareContents.BLACK));
    
    // Place a White piece at c4, an invalid move
    assertFalse("White piece to c4 should be invalid", play.place(2, 4, SquareContents.WHITE));
    
    // Place a White piece at c5, a valid move
    assertTrue("White piece to c5 should be valid", play.place(2, 5, SquareContents.WHITE));
    
    // Place a Black piece at c4, a valid move
    assertTrue("Black piece to c4 should be valid", play.place(2, 4, SquareContents.BLACK));
    
    // Place a White piece at d3, an invalid move
    assertFalse("White piece to d3 should be invalid", play.place(4, 3, SquareContents.WHITE));
    
    // Place a White piece at c3, a valid move
    assertTrue("White piece to c3 should be valid", play.place(2, 3, SquareContents.WHITE));
    
    // The boards should now be unequal
    assertFalse("Test ending Board inequality with equals", starting.equals(play));
  }

}
